package com.gopay.scheduler.service.fund.impl;

import com.gopay.common.domain.acps.model.AcctMastBean;
import com.gopay.remote.acps.service.AcctTransRemoteService;
import com.gopay.scheduler.service.fund.FundAcctMastService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("fundAcctMastService")
public class FundAcctMastServiceImpl implements FundAcctMastService {

    @Resource(name = "acctTransRemoteService")
    private AcctTransRemoteService acctTransRemoteService;

    @Override
    public AcctMastBean getAccount(String custId, String acctCode) {
        List<AcctMastBean> acctMastBeanList = getAccountListByCustId(custId);
        for (AcctMastBean acctMastBean : acctMastBeanList) {
            if (acctCode.equals(acctMastBean.getProdCodeStr())){
                return acctMastBean;
            }
        }
        return null;
    }

    @Override
    public List<AcctMastBean> getAccountListByCustId(String custId) {
        List<AcctMastBean> accounts = acctTransRemoteService.getAccounts(custId);
        return accounts;
    }
}
